package com.zhiyou100.controller;

import java.util.ArrayList;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhiyou100.model.Discuss;
import com.zhiyou100.service.DiscussService;
import com.zhiyou100.vo.ResponseVo;

@RestController
public class DiscussController {
	@Autowired
	private DiscussService discussService;
	@GetMapping("/discusss/{projectId}")
	public ResponseVo<ArrayList<Discuss>> findAll(@PathVariable int projectId){
		ArrayList<Discuss> al = discussService.findAll(projectId);
		return new ResponseVo<ArrayList<Discuss>>(200, "请求成功", al);
	}
	@GetMapping("/discusss/{progressId}")
	public ResponseVo<ArrayList<Discuss>> findUpdate(@PathVariable int progressId){
		ArrayList<Discuss> al = discussService.findAll(progressId);
		return new ResponseVo<ArrayList<Discuss>>(200, "请求成功", al);
	}
	
	@PostMapping("/discusss")
	public ResponseVo<String> add(@RequestBody Discuss discuss){
		discussService.add(discuss);
		return new ResponseVo<String>(200, "添加成功", null);
	}
	@PostMapping("/discusss")
	public ResponseVo<String> addUpdate(@RequestBody Discuss discuss){
		discussService.add(discuss);
		return new ResponseVo<String>(200, "添加成功", null);
	}
}
